Imports System.Xml
Public Class frmATTRIBUTE
    Dim dt As DataTable = BLL.ObjectGetAll("ATTRIBUTE_LOAD")
    Dim dv As DataView
    Public Attribute As String = ""
    Private Sub cb_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        CType(sender, Janus.Windows.EditControls.UIComboBox).DroppedDown = True
    End Sub

    Private Sub frmATTRIBUTE_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Try
            GC.Collect()
            Me.Dispose()
        Catch ex As Exception

        End Try
    End Sub
    Private Sub frmATTRIBUTE_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PublicFunction.NewFormLoad(Me)
        dv = New DataView(dt)
        dv = dv.ToTable(True, "ATTRIBUTE_NAME").DefaultView
        For i As Integer = 0 To dv.Count - 1
            Dim pn As New Panel
            pn.Dock = DockStyle.Top
            pn.Height = 40
            pn.BackColor = Color.Transparent
            uiPanel1.InnerContainer.Controls.Add(pn)

            Dim cb As New Janus.Windows.EditControls.UIComboBox
            cb.Dock = DockStyle.Fill
            cb.Name = dv(i).Item("ATTRIBUTE_NAME").ToString
            AddHandler cb.Click, AddressOf cb_Click
            pn.Controls.Add(cb)
            Dim dv1 As New DataView(dt)
            dv1.RowFilter = "ATTRIBUTE_NAME='" + dv(i).Item("ATTRIBUTE_NAME").ToString + "'"
            cb.DisplayMember = "ATTRIBUTE_VALUE"
            cb.ValueMember = "ATTRIBUTE_VALUE"
            cb.DataSource = dv1
            If dv1.Count > 0 Then
                cb.SelectedIndex = 0
            End If

            Dim lb As New Label
            lb.AutoSize = False
            lb.Dock = DockStyle.Left
            lb.TextAlign = ContentAlignment.MiddleLeft
            lb.Text = dv(i).Item("ATTRIBUTE_NAME").ToString
            pn.Controls.Add(lb)
        Next
        If Attribute <> "" Then
            Dim sr As New System.IO.StringReader(Attribute)
            Dim doc As New Xml.XmlDocument
            doc.Load(sr)
            Dim reader As New Xml.XmlNodeReader(doc)
            While reader.Read()
                Select Case reader.NodeType
                    Case Xml.XmlNodeType.Element
                        If reader.Name = "Att" Then
                            'MessageBox.Show(reader.GetAttribute("name"))
                            'MessageBox.Show(reader.GetAttribute("value"))
                        End If
                End Select
            End While


        End If
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Attribute = "<Attribute>"
        For Each ctr As Control In uiPanel1.InnerContainer.Controls
            For Each ctr1 As Control In ctr.Controls
                If TypeOf ctr1 Is Janus.Windows.EditControls.UIComboBox Then
                    Attribute = Attribute + "<Att name= """ + ctr1.Name + """ value= """ _
                            + CType(ctr1, Janus.Windows.EditControls.UIComboBox).SelectedValue + """/>"
                End If
            Next
        Next
        Attribute = Attribute + "</Attribute>"
    End Sub
End Class